package com.xuzm.netty.test;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;

public class SocketClient {
    public static void main(String[] args) {
        try {
            String serverAddress = "localhost";
            int serverPort = 8099;

            Socket socket = new Socket(serverAddress, serverPort);
            System.out.println("Connected to server");

            PrintWriter out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()), true);
//            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));

            // Send data to server
            out.println("Hello from Java client");

            // Receive data from server
//            String response = in.readLine();
//            System.out.println("Received data from server: " + response);

            socket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
